package com.zyz.M_File和IO流.IO流.对象流;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

/**
 * @author: vick
 * @Date: 2025/4/10
 * @Description:
 * @version: 1.0
 */
public class Demo1 {
    public static void main(String[] args) throws IOException {
        String name = "李老师";
        int age = 100;
        char sex = '男';
        double price = 500.5;
        boolean flag = true;

        File file = new File("my.txt");
        FileOutputStream fileOutputStream = new FileOutputStream(file);
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
        objectOutputStream.writeUTF(name);
        objectOutputStream.writeInt(age);
        objectOutputStream.writeChar(sex);
        objectOutputStream.writeDouble(price);
        objectOutputStream.writeBoolean(flag);
        objectOutputStream.close();

    }
}
